package com.xyy.saas.payment.util;

import org.apache.commons.lang.StringUtils;
import util.AESUtil;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author: wuqiongda
 * @Date: 2019/11/14 10:23
 */
public class MatcherUtil {

    /**
     * 判断日期格式是否符合规则 yyyy-mm-dd
     */
    public static boolean isValidDate(String date){
        String pattern = "\\d{4}(\\-)\\d{1,2}\\1\\d{1,2}";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(date);
        return m.matches();
    }

    /**
     * 判断字符串是否含有特殊字符
     * @param code
     * @return
     */
    public static boolean isHasSpecialSymbol(String code){
        if(code.replaceAll("[\u4e00-\u9fa5]*[a-z]*[A-Z]*\\d*-*_*\\s*", "").length()==0){
            //如果不包含特殊字符
            return false;
        }
        return true;

    }

    /**
     * 匹配国内手机号正则
     */
    public static boolean isValidPhoneNo(String phoneNo){
//        String pattern = "0?(13|14|15|17|18|19)[0-9]{9}";
//        Pattern r = Pattern.compile(pattern);
//        Matcher m = r.matcher(phoneNo);
//        return m.matches();
        //手机号匹配有问题，先下掉
        return true;
    }
    /**
     * 身份证校验正则
     */
    public static boolean isValidIdCard(String idCard){
        String pattern = "\\d{17}[\\d|x|X]|\\d{15}";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(idCard);
        return m.matches();
    }
    /**
     * 判断银行卡号的正则
     */
    public static boolean isValidBankCard(String bankCard){
        String pattern = "\\d{16}|\\d{17}|\\d{18}|\\d{19}";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(bankCard);
        return m.matches();
    }
    /**
     * email判断 正则
     */
    public static boolean isValidEmail(String email){
        String pattern = "\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(email);
        return m.matches();
    }
    /**
     * 判断URL是否合法
     * @param url
     * @return
     */
    public static final boolean isLegalURL(String url) {
        String pattern = "^([hH][tT]{2}[pP]://|[hH][tT]{2}[pP][sS]://)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\/])+$";
        int URL_MAX_LENGTH = 120;
        if (!StringUtils.isBlank(url) || url.length() > URL_MAX_LENGTH) {
                Pattern httpPattern = Pattern.compile(pattern);
                if (httpPattern.matcher(url).matches()) {
                    return true;
                }
                return false;
            } else {
            return false;
        }
    }

    public static void main(String[] args) throws Exception {
        String tel_no = "98I3pCq/Z/XovlS/ql4N3khTVrYezbr2N9k+bacQGhGNdu7D929XIzBHqbJMsoSBW3tIHj48mv+WsOxt+4zNJzYEnZZYWdWJWnoilDQ7TkiO4H1g502VXosJ/az6FL1cZ5ppDmshvUih8ySzpnD0exPntTR6W3qhBSJUp2E3r8IpU7Wzwm3kZ4nhxJ/66vbTuIM9YvQki6VysnDk2cvkfzugiXXUX4Zxxe8e4LfUjQ9nd4qfB3YLlnCQqSqg39yZlhIRuVwea7DbKT99fJVmkFgqMGjadE+gg8zNlZTM/BvYlhzlYrzA5lx3MTK/9tLL13s7kXR5O6ZcWspcWc4IobzDjljHiET2NfODj3+xV+4qfAR7EAq6S/Z5LTghfYk80A9femZOqIh+XAtkyK1diR2BLwZ2ZwOWyMAZY4xZtqC1F/QjBNqMv6AT93CRXtOTAhRCOnUmHd8U2qxV6vNU6C3Ygf+Jzm38TrjJeEOEtXnoTVSAW8S1J4+yq1+ZNjrBHKJaq2WgYRdupYaFSiFcFK1xTLpeIUvm15auHMC9Vo/Yd1X9HuuuY/517WUdYBInBuggmnx2mlWHdWT64yqRF2pWSVn+8tX27oNMcLmXie4=";
        String pic_info = "uSUvG83lWNqO11+E/KC+RRgiACe9W9xYLj5YKe04RhivjQYY20q094eAzZ4KuE+zCXBw3jcXSbeowATuWBcJfm/8V7n32gu6VCY+kA2/EVu0kobQZXWvhU7D7ehgEBNLdQVol7G/pIqO17MXFM8fLib3KzuPDcvzNIM2oJBDXLvEZRxHSDNH4rF+x8OBCnbi3NBoyvbjOKNrM9NdjnXBkKLNto5sMy2aw2th6wae50Y=";
        String contact_info = "DglA0boHdQBvVBOJ2KNqXg==";
        String basic_info = "YsRQC9FWiKcajAh3x/q4LIZsZsmWET9tvFFCaS0PnAPmHYjmg3bw/9+69jFuENhZQ+R0xFXPF/2VTqw0IwKMiW+W56nTAsZFJ+hVMQo3aCjScnYqAYZjmbXy6o8Y0BCscAoc6ZYWQkGCcxb3xIPJ1d9qmbcGUSraJiiEy7kbrB2q3ca4WaI6LQtUC70D+4/jX/M9XYgXSnyCCMUXUB2hfhMLIakqaAMArb6Pt2dKS6Kh9GKcLCx/kVFMHyA9FH5LkMbTqKUqzo2OGHYtgk+spA==";
        String settle_info = "98I3pCq/Z/XovlS/ql4N3mIdSWjYgCTQY6cFm/DJL8Eea7OSOmvxVZ0vMFu/ylq8J691N9lnAyI2ZnXZeENnD3jKIfMpS8WED8YFszBRSLEWXBhI+/i3vH8nIdnLQL0x2N4eNMmQTICruDoRGoFSBJs90d+s0n2WPrSocHl8FFEvqmeeEYMbobeiuNzuImOK8dNjC1jpoSCVNcvJwbpGInvkJI56lBkgzk6jW8ksvltsgai7GnAEDLI8IFGNxkic3r3taxh/D29gxyKEU5YawCRGGf7ojScx5B8R7F7GPOHwG73XfOAATrVkWK6IpOehs+VEaRmL/khZApYl6H3pnWfKOB48B1oBK1io2GiP+H5O4MocZ3ujuxplx6DU6OPFSvcHVRhwgG5Gpu18fVkrrRqjv8E8qCwU0daRjIy1hmE=";
        tel_no = AESUtil.decrypt(tel_no, "c9d40faceff82565386d648158c3f1eb");
        pic_info = AESUtil.decrypt(pic_info, "c9d40faceff82565386d648158c3f1eb");
        contact_info = AESUtil.decrypt(contact_info, "c9d40faceff82565386d648158c3f1eb");
        basic_info = AESUtil.decrypt(basic_info, "c9d40faceff82565386d648158c3f1eb");
        settle_info = AESUtil.decrypt(settle_info, "c9d40faceff82565386d648158c3f1eb");

        System.out.println("tel_no:"+tel_no);
        System.out.println("pic_info:"+pic_info);
        System.out.println("contact_info:"+contact_info);
        System.out.println("basic_info:"+basic_info);
        System.out.println("settle_info:"+settle_info);

    }
}
